package com.android.fastride.model.http;

import com.android.fastride.FastRideApplication;
import com.android.fastride.exception.NetworkNotConnectException;
import com.peng.library.mantis.kit.Kits;

import rx.Subscriber;

/**
 * 网络监听器
 * <p>
 * Created by pengyuantao on 2017/11/7 11:46.
 */

public abstract class NetWorkSubscriber<T> extends Subscriber<T> {
	@Override
	public void onStart () {
		//判断当前的网络是否连接正常
		if (Kits.NetWork.NETWORK_TYPE_DISCONNECT.equals(Kits.NetWork.getNetworkTypeName(FastRideApplication.getApp()))) {
			onError(new NetworkNotConnectException("网络没有连接"));
			if (!isUnsubscribed()) {
				unsubscribe();
			}
		}
	}
}
